package com.example.demo.OtherCoding;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-06-24
 * Time: 10:11
 */
public class TestArrayList {

    public static void main1(String[] args) {
        List<Integer> list1 = Arrays.asList(1, 2, 3);
        System.out.println("通过数组转换：" + (list1.toArray().getClass() == Object[].class));

        List<Integer> list2 = new ArrayList<>(Arrays.asList(1, 2, 3));
        System.out.println("通过集合转换：" + (list2.toArray().getClass() == Object[].class));
    }


    public static List<Integer> getList() {
        ArrayList<Integer> list = new ArrayList<>();
        // 填充 list...
        return Collections.unmodifiableList(list);
    }

    public static void main(String[] args) {
        HashMap<String,Integer> map = new HashMap<>();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(1);
        list.add(1);
        list.add(1);
        Integer integer = new Integer(1);
        list.remove(integer);
        System.out.println(list);

        //list.trimToSize(); // 手动调用 trimToSize() 方法，减小容量
    }

}
